unit EnterText;

interface

uses
  Database,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons;

type
  TFormEnterText = class(TForm)
    LabelText: TLabel;
    BtnOK: TBitBtn;
    BtnCancel: TBitBtn;
    EditText: TEdit;
    procedure EditTextChange(Sender: TObject);
    procedure BtnCancelClick(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure EditTextKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
    replacement: string;
  end;

var
  FormEnterText: TFormEnterText;

implementation

{$R *.DFM}

procedure TFormEnterText.FormCreate(Sender: TObject);
begin
  replacement:='';
end;

procedure TFormEnterText.EditTextChange(Sender: TObject);
begin
  if length(EditText.text) > 1 then BtnOK.enabled:=true
  else BtnOK.enabled:=false;
end;

procedure TFormEnterText.BtnCancelClick(Sender: TObject);
begin
  replacement:='';
  close;
end;

procedure TFormEnterText.BtnOKClick(Sender: TObject);
begin
  replacement:=EditText.text;
  close;
end;

procedure TFormEnterText.EditTextKeyPress(Sender: TObject;
  var Key: Char);
begin
  if key = #13 then begin
    BtnOK.click;
    key:=#0;
  end;
end;

end.
